package com.example.touchdemo.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

public class TouchView extends AppCompatTextView {
    public  static  final String TAG="view";
    public TouchView(@NonNull Context context) {
        super(context);
    }
    public TouchView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
    @SuppressLint("ClickableViewAccessibility")
    @Override
    public  boolean onTouchEvent(MotionEvent event){
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Log.d(TAG, " ----------onTouchEvent----------down");
                break;

            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, " ----------onTouchEvent----------move");
                break;
            case MotionEvent.ACTION_UP:
                Log.d(TAG, "----------onTouchEvent----------up");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.d(TAG, "----------onTouchEvent----------cancel");
                break;
        }
        return super.onTouchEvent(event);

    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                Log.d(TAG, "------------dispatchTouchEvent----------down ");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "-----------dispatchTouchEvent------------move");
            case MotionEvent.ACTION_UP:
                Log.d(TAG, "----------dispatchTouchEvent----------up");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.d(TAG, "----------dispatchTouchEvent----------cancel");
                break;
        }
        return super.dispatchTouchEvent(event);
    }
}
